<template>
	<view class="container" :style="[ctop()]">
		<view :style="[top()]" class="top fixed">
			<view class="flex j-between a-center">
				<view class="flex a-center rule" @tap="back()">
					<u-icon name="arrow-left" size="40"></u-icon>
				</view>
				<view class="title ecllipse flex j-center">
					<view>我的发布</view>
				</view>
				<view class="flex j-end a-center place rule">
					<u-icon name="plus-circle" size="40" class="msg" color="#666"></u-icon>
					<view>发布任务</view>
				</view>
			</view>
		</view>
		<view class="menus">
			<u-tabs :font-size="32" :list="menus" bg-color="transparent" :is-scroll="true" :current="current" @change="change"></u-tabs>
		</view>
		<view>
			<task-item v-for="(item,i) in list" :key="i" :item="item"></task-item>
		</view>
	</view>
</template>

<script>
import taskItem from './components/my-post-item.vue'
export default {
	components:{taskItem},
	data() {
		return {
			//0全部任务 1进行中 2已关闭 3已暂停 4已取消 5已过期  6审核未通过 7未审核
			menus:[{name:'全部任务'},{name:'进行中'},{name:'已关闭'},{name:'已暂停'},{name:'已取消'},{name:'已过期'},{name:'审核未通过'},{name:'未审核'}],
			current:0,
			jx_task:[
				{status:1,name:'商家拉新',coin:1000,top:true,t_name:'互砍任务',jd:52,wc:10,sy:20,src:'https://cdn.uviewui.com/uview/common/logo.png'},
				{status:2,name:'商家拉新',coin:1000,top:true,t_name:'互砍任务',jd:0,wc:10,sy:20,src:'https://cdn.uviewui.com/uview/common/logo.png'},
				{status:3,name:'商家拉新',coin:1000,top:true,t_name:'互砍任务',jd:1,wc:10,sy:20,src:'https://cdn.uviewui.com/uview/common/logo.png'}
			],
			list:[]
		}
	},
	onLoad() {
		this.myfabu(this.current)
	},
	methods: {
		top(){
			let pdt = 0
			uni.getSystemInfo({  
		        success:function(e){  
		            // #ifndef MP  
		            if(e.platform == 'android') {  
		                pdt = e.statusBarHeight  
		            }else {  
		                pdt = e.statusBarHeight + 45  
		            }  
		            // #endif  
		
		            // #ifdef MP-WEIXIN  
		            let custom = wx.getMenuButtonBoundingClientRect()  
		            pdt = custom.bottom + custom.top - e.statusBarHeight  
		            // #endif  
		
		            // #ifdef MP-ALIPAY  
		            pdt = e.statusBarHeight + e.titleBarHeight  
		            // #endif  
		        }  
		    })  
			return {paddingTop:(pdt+10)+'px'}
		},
		ctop(){
			let pdt = 0
			uni.getSystemInfo({  
		        success:function(e){  
		            // #ifndef MP  
		            if(e.platform == 'android') {  
		                pdt = e.statusBarHeight  
		            }else {  
		                pdt = e.statusBarHeight + 45  
		            }  
		            // #endif  
		
		            // #ifdef MP-WEIXIN  
		            let custom = wx.getMenuButtonBoundingClientRect()  
		            pdt = custom.bottom + custom.top - e.statusBarHeight  
		            // #endif  
		
		            // #ifdef MP-ALIPAY  
		            pdt = e.statusBarHeight + e.titleBarHeight  
		            // #endif  
		        }  
		    })  
			return {paddingTop:(pdt+44)+'px'}
		},
		change(i){
			this.current = i
			console.log(i)
			this.myfabu(i)
		},
		myfabu(type){
			this.$api.myfabu({type:type}).then(res => {
				this.list = res.data.list
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.container{padding: 0 24rpx;}
.top{padding: 18rpx 24rpx;width: 100%;left:0;right: 0;top:0;z-index: 10;color: #333;background-color: #f9f9f9;
	.title{font-weight: bold;font-size: 36rpx;width: 400rpx;}
	.rule{font-size: 32rpx;width: 33%;}
	.msg{width: 44rpx;height: 44rpx;margin-right: 16rpx;}
}
.menus{margin-bottom: 32rpx;}
</style>
